package javase0828;

import java.io.*;
import java.net.Socket;
import java.util.HashMap;

/**
 * socket客户端
 *
 */
public class Demo01 {
    public static void main(String[] args) throws Exception {
        Socket socket = new Socket("127.0.0.1", 8888);
        ObjectInputStream ois = null;
        OutputStream oos = null;
        oos = socket.getOutputStream();
        InputStream is = socket.getInputStream();

        String s = "hello";
        oos.write(s.getBytes());
        oos.flush();
        socket.shutdownOutput();


        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader bufferedReader = new BufferedReader(isr);

        String ss = bufferedReader.readLine();
        System.out.println(ss);

        oos.close();
        socket.close();
    }
}
